
using System;
using System.Collections.Generic;
using BTKERP.Model;
using BTKERP.DAL.DataAccess;
using System;

namespace BTKERP.DAL
{
	#region ShelfDAL
	public class ShelfDAL : DBContext
	{
		public List<Shelf> GetAll()
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_ShelfsSelectAll");
            return GetEntityList<Shelf>(cmd);
        }

        public Shelf GetById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_ShelfSelect");
            cmd.AddParameter("@Id", id);
            return GetSingleEntity<Shelf>(cmd);
        }

		public List<Shelf> GetByDynamicSQL(string sqlCondition)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_ShelfSelectDynamic");
            cmd.AddParameter("@SQL", sqlCondition);
            return GetEntityList<Shelf>(cmd);
        }

        public Shelf Add(string paramCode, string paramBarcode, string paramName, string paramDescription, Guid paramWarehouseId,
                                int paramLevels, decimal paramCapacity, decimal paramWeight, decimal paramLength,
                                decimal paramWidth, decimal paramHeight, decimal paramThickness, string paramCreatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_ShelfInsert");
            cmd.AddParameter("@Code", paramCode);
            cmd.AddParameter("@Barcode", paramBarcode);
            cmd.AddParameter("@Name", paramName);
            cmd.AddParameter("@Description", paramDescription);
            cmd.AddParameter("@WarehouseId", paramWarehouseId);
            cmd.AddParameter("@Levels", paramLevels);
            cmd.AddParameter("@Capacity", paramCapacity);
            cmd.AddParameter("@Weight", paramWeight);
            cmd.AddParameter("@Length", paramLength);
            cmd.AddParameter("@Width", paramWidth);
            cmd.AddParameter("@Height", paramHeight);
            cmd.AddParameter("@Thickness", paramThickness);
            cmd.AddParameter("@CreatedBy", paramCreatedBy);
            return GetSingleEntity<Shelf>(cmd);
        }

        public bool DeleteById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_ShelfDelete");
            cmd.AddParameter("@Id", id);
            return ExecuteCommand(cmd);
        }

        public Shelf UpdateById(Guid paramId, string paramCode,	string paramBarcode, string paramName, string paramDescription,	Guid paramWarehouseId,
                                int paramLevels, decimal paramCapacity, decimal paramWeight, decimal paramLength,
                                decimal paramWidth, decimal paramHeight, decimal paramThickness, string paramUpdatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_ShelfUpdate");
			cmd.AddParameter("@Id", paramId);
			cmd.AddParameter("@Code", paramCode);
			cmd.AddParameter("@Barcode", paramBarcode);
			cmd.AddParameter("@Name", paramName);
			cmd.AddParameter("@Description", paramDescription);
			cmd.AddParameter("@WarehouseId", paramWarehouseId);
			cmd.AddParameter("@Levels", paramLevels);
			cmd.AddParameter("@Capacity", paramCapacity);
			cmd.AddParameter("@Weight", paramWeight);
			cmd.AddParameter("@Length", paramLength);
			cmd.AddParameter("@Width", paramWidth);
			cmd.AddParameter("@Height", paramHeight);
			cmd.AddParameter("@Thickness", paramThickness);
			cmd.AddParameter("@UpdatedBy", paramUpdatedBy);
            return GetSingleEntity<Shelf>(cmd);
        }
		
	}
	#endregion
}
